<?php
import('baseview.class.php');

define('REQUEST_S_OK',200);
define('REQUEST_F_NICK_NEEDED', 221);
define('REQUEST_F_UNKOWN_REASON', 222);
define('REQUEST_F_TOO_MUCH',223);// 请求过于频繁

class ViewRequest extends BaseView{

	public function getViewByCode($code){
		switch($code){
			case REQUEST_S_OK:
				return parent::getSuccessView(REQUEST_S_OK, 'ok');
				break;
			case REQUEST_F_NICK_NEEDED:
				return parent::getFailedView(REQUEST_F_NICK_NEEDED, 'Nick Name is needed.');
				break;
			case REQUEST_F_TOO_MUCH:
				return parent::getFailedView(REQUEST_F_TOO_MUCH, 'Request frequently.');
			case REQUEST_F_UNKOWN_RESON:
			default:
				return parent::getFailedView(REQUEST_F_UNKOWN_REASON, 'Unkown reason.');
		}
	}

	public function getRequestSuccessView($verify_code){
		$view = parent::getSuccessView(REQUEST_S_OK, 'ok');
		return BaseView::mergeViews($view, array('code'=>$verify_code));
	}

}